# from celery import task
from myshop.celery import app
from django.core.mail import send_mail
from orders.models import Order


@app.task
def order_created(order_id):
    """
    当订单创建成功的时候发送一封邮件
    """
    order = Order.objects.get(id=order_id)
    subject = 'Order nr. {}'.format(order.id)
    message = 'Dear %s, \n\n你的订单创建成功！.\你的订单号是 %s。'%(order.first_name, order.id)
    mail_sent = send_mail(subject, message, 'admin@myshop.com', [order.email])

    return mail_sent




